% This file is used to define the Global variables, initial conditions and call the required files.
% The variables are:
% p: represents zeta : wave height
% q : represents phi : surface velocity potential
% r : represents psi : Vertical Structure
% 1-D case .. in X direction

global U  h  g  p  q r  nt dx h1 x p_global tmax L steps y itermax Q a;
%----- Physical Parameters----------

U = 1; % Current Velocity of the wave. Assumed Constant
h = 50; % height of the bed, assumed constant
g= 9.8; % Gravitational COnstant

%------------ Simulation Parameters % -----------------
tmax = 100;     % max time, s
L=100;
x = 50;         % number of axial nodes
steps = x-1;    % number of axial steps
dx = L/steps;   % axial step spacing, delta x
% Check the CFL condition:
dt1 = 0.5*dx/sqrt(g*h);

%--- Initial Conditions ----------
pi1=1;
qi=1;
r=zeros(x,1);

for i=1:x
    p(i,1) = pi1*cos(4*pi*(i-1)*dx/L);
    q(i,1) = qi;
    r(i,1) =1.0;
end
i=1;
Benchmark(2);
A(1:x,i)=y(end,1:x);
B(1:x,i)=y(end,x+1:2*x);
C(1:x,i)=y(end,2*x+1:3*x);

% % Run the custom Program
%itermax = 20;
%i=3;
dt_v =[1.0 0.1 0.01];
for i =1 : length(dt_v)
    dt = dt_v(i);
    time_discretizers(dt,5);
    A(1:x,i+1) = p;
    B(1:x,i+1)=q;
    C(1:x,i+1)=r;
    X = sprintf('The Norm of the Error for Zeta is %f' , norm_L2(A(:,1),A(:,i+1)));
    disp(X);
    X = sprintf('The Norm of the Error for varphi is %f' ,  norm_L2(B(:,1),B(:,i+1)));
    disp(X);
end